from problem_agent import ProblemAgent
from algorithm import Heuristic
from astar import *


class Astar_Agent(ProblemAgent):
    def solve(self, problem_state, w=0.5):
        return AStar().find(problem_state, DisplacedHeuristicManhaten(), w)

 
# Manhaten distance heuristic    
class DisplacedHeuristicManhaten(Heuristic):
    def evaluate(self, state):
        current = state.myLocation
        target = state.target
        
        #print "*** H for current(%s) and target (%s) is %s",current, target, abs(target[0][0] - current[0])
        if current is None:
            return 0
        return  abs(target - current[0])